﻿using D.Traceability.Domain;
using Microsoft.EntityFrameworkCore;

namespace D.Traceability.Infrastructure
{
    public class SDbContext : DbContext
    {
        public SDbContext(DbContextOptions options) : base(options)
        {
        }

        /// <summary>
        /// 溯源信息表
        /// </summary>
        public DbSet<SU_TraceabilityModel> SU_TraceabilityModel { get; set; }

        /// <summary>
        /// 养殖信息表
        /// </summary>
        public DbSet<SU_BreedModel> SU_BreedModel { get; set; }
        /// <summary>
        /// 深加工信息表
        /// </summary>
        public DbSet<SU_DeepModel> SU_DeepModel { get; set; }
        /// <summary>
        /// 企业信息表
        /// </summary>
        public DbSet<SU_EnterpriseModel> SU_EnterpriseModel { get; set; }
        /// <summary>
        /// 商品信息表
        /// </summary>
        public DbSet<SU_GoodsModel> SU_GoodsModel { get; set; }
        /// <summary>
        /// 免疫信息表
        /// </summary>
        public DbSet<SU_ImmunityModel> SU_ImmunityModel { get; set; }
        /// <summary>
        /// 信息完善度表
        /// </summary>
        public DbSet<SU_ImproveModel> SU_ImproveModel { get; set; }
        /// <summary>
        /// 图片信息表
        /// </summary>
        public DbSet<SU_PictureModel> SU_PictureModel { get; set; }
        /// <summary>
        /// 屠宰信息表
        /// </summary>
        public DbSet<SU_SlaughterModel> SU_SlaughterModel { get; set; }
        /// <summary>
        /// 供应商信息表
        /// </summary>
        public DbSet<SU_SupplierModel> SU_SupplierModel { get; set; }

        /// <summary>
        /// TraceaBatch 设置为唯一
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<SU_TraceabilityModel>()
                .HasIndex(u => u.TraceaBatch)
                .IsUnique();
        }





    }
}
